module.exports = (parsed, when = 'always', value = '.*') => {
  const header = parsed.header || '';

  // 如果 value 是字符串，则转换成正则表达式
  const regex = typeof value === 'string' ? new RegExp(value) : value;

  const isMatch = regex.test(header);
  const pass = when === 'always' ? isMatch : !isMatch;

  return [pass, `header ${when === 'always' ? 'must match' : 'must not match'} pattern ${regex}`];
};
